package com.nbcio.iot.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Modbus 配置属性
 */
@Data
@Component
@ConfigurationProperties(prefix = "iot.modbus")
public class IotModbusProperties {
    private Tcp tcp = new Tcp();
    private Rtu rtu = new Rtu();

    @Data
    public static class Tcp {
        private String host = "127.0.0.1";
        private int port = 502;
        private int timeoutMs = 2000;
        private int retries = 1;
        private boolean enabled = false;
    }

    @Data
    public static class Rtu {
        private String portName = "COM1"; // Windows 示例，Linux 可为 /dev/ttyUSB0
        private int baudRate = 9600;
        private int dataBits = 8;
        private int stopBits = 1;
        private int parity = 0; // 0-None,1-Odd,2-Even
        private int timeoutMs = 2000;
        private int retries = 1;
        private boolean enabled = false;
    }
} 